﻿using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace FrameworkCore.Modules.Engines;

#nullable disable

/// <summary>
/// 实现此接口的类可以作为组成 AiBLSmartEdu 引擎的各种服务的门户。
/// 大多数 AiBLSmartEdu 功能的编辑功能、模块和实现通过此接口访问。
/// </summary>
public partial interface IEngine
{
    /// <summary>
    /// 添加和配置服务
    /// </summary>
    /// <param name="services">服务描述符的集合</param>
    /// <param name="configuration">应用程序的配置</param>
    void ConfigureServices(IServiceCollection services, IConfiguration configuration);

    /// <summary>
    /// 配置 HTTP 请求管道
    /// </summary>
    /// <param name="application">用于配置应用程序请求管道的构建器</param>
    void ConfigureRequestPipeline(IApplicationBuilder application);

    /// <summary>
    /// 解析依赖项
    /// </summary>
    /// <param name="scope">作用域</param>
    /// <typeparam name="T">解析的服务类型</typeparam>
    /// <returns>解析的服务</returns>
    T Resolve<T>(IServiceScope scope = null) where T : class;

    /// <summary>
    /// 解析依赖项
    /// </summary>
    /// <param name="type">解析的服务类型</param>
    /// <param name="scope">作用域</param>
    /// <returns>解析的服务</returns>
    object Resolve(Type type, IServiceScope scope = null);

    /// <summary>
    /// 解析所有依赖项
    /// </summary>
    /// <typeparam name="T">解析的服务类型</typeparam>
    /// <returns>解析的服务集合</returns>
    IEnumerable<T> ResolveAll<T>();

    /// <summary>
    /// 解析未注册的服务
    /// </summary>
    /// <param name="type">服务类型</param>
    /// <returns>解析的服务</returns>
    object ResolveUnregistered(Type type);
}